import java.util.*;


  class ListNode {
    int val;
    ListNode next = null;
    public ListNode(int val) {
      this.val = val;
    }
  }


public class Solution {

    public ListNode deleteDuplicates (ListNode head) {
        if(head==null){
            return head;
        }
        ListNode cur=head;

        while(cur!=null&&cur.next!=null){
            if(cur.next.val==cur.val){
                cur.next=cur.next.next;
                continue;
            }
            cur=cur.next;
        }
        return head;
    }
}